
def is_str_close(s):
    b = []
    flag = 0
    for i in s:
        if i=='{' or i=='[' or i=='(':
            b.append(i)
        elif i == '}' and b.pop()!='{':
            flag=1
        elif i == ']' and b.pop()!='[':
            flag=1
        elif i==')' and b.pop() !='(':
            flag=1
    if len(b) != 0:
        flag=1
    if flag == 1:
        return False
    elif flag==0:
        return True

s = input()
print(is_str_close(s))